import { ZYSDK } from "../../../../ZYSDK";
import adModel from "../../../main/view/adView/adModel";
import { ZYEventMgr } from "../../manager/YLEventMgr";
import MyTools from "../../util/MyTools";
/**
 * 微信骗点
 * @author: xj.huang
 * @date: 2021/08/04 09:44:08
 */
export default class wxAdRipoff {
    constructor() { }

    /**按钮延时出现 */
    public isShowBtn(btn: Laya.Image | Laya.Button, pageInfo: any = {}, isShowBanner, isPop = false) {
        let isLevel = true;
        btn.visible = false;
        let timerNum = 1000
        if (ZYSDK.getLateOff && isLevel && MyTools.getRandomPer(pageInfo.per)&&!isPop) {
            this.onCloseBanner()
            let wxTimer = (pageInfo.wx_show + pageInfo.btn_showTime) * timerNum;
            let wxHTimer = (pageInfo.delay+pageInfo.wx_show  + pageInfo.btn_showTime )*timerNum
            // console.log("pageInfo.wx_show",wxTimer,wxHTimer,pageInfo)
            Laya.timer.once(pageInfo.btn_showTime * timerNum, this, this.onShowBtn, [btn])
            Laya.timer.once(wxTimer, this, this.onShowBanner1, [isShowBanner])
            Laya.timer.once(wxHTimer,this, this.onShowBtnAni, [btn, pageInfo.btn_move_time.timer, isPop]);
            
        } else {
            btn.visible=true;
            btn.bottom = adModel.bnnerheight * 2.5 ;
            !isPop&&this.onShowBanner1()
        }
    }
    /**显示按钮 */
    private onShowBtn(btn) {
        btn.visible = true;
    }
    /**显示广告 */
    private onShowBanner1() {
        ZYEventMgr.emit(ADEvent.SHOW_BANNER_AD)
        console.log("显示->bannerShowing")
    }
    /**按钮上移动 */
    private onShowBtnAni(btn, timer = 1,isPop) {
        if(isPop){
            btn.visible=true;
            return
        }
        Laya.Tween.to(btn, { bottom: adModel.bnnerheight * 2.5 + 50 }, timer * 1000)
        console.log("显示->bannerShowing")
    }
    /**隐藏广告 */
    private onCloseBanner() {
        Laya.timer.clearAll(this)
        ZYEventMgr.emit(ADEvent.HIDE_BANNER_AD,true)
        console.log("关闭->bannerShowing")
    }

}
